package org.gwtEss.table;

import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;

public /*abstract */class ColWidget<VO>{
	private String colName; 
	private int colWidth = -1;
	private boolean visible = true;
	private int suggestedWidth = 100;
	private Boolean sortAsc = null;//true= asc; false = dsc; null = not set 

	public ColWidget(String colName, int suggestedWidth) {
		this.suggestedWidth = suggestedWidth;
		this.suggestedWidth = suggestedWidth; 
		this.colName = colName;
	}
	public ColWidget(String colName, int colWidth, boolean visible) {
		super();
		this.colName = colName;
		this.colWidth = colWidth;
		this.visible = visible;
	}
	public ColWidget(String colName, int suggestedWidth, Boolean sortAsc) {
		this.suggestedWidth = suggestedWidth;
		this.suggestedWidth = suggestedWidth; 
		this.colName = colName;
		this.sortAsc = sortAsc; 
	}
	public ColWidget(String colName, int colWidth, boolean visible, Boolean sortAsc) {
		super();
		this.colName = colName;
		this.colWidth = colWidth;
		this.visible = visible;
		this.sortAsc = sortAsc;
	}

	public void processCellFormatter(){}
	
	public int getSuggestedWidth() {
		return suggestedWidth;
	}
	public Boolean getSortAsc() {
		return sortAsc;
	}
	public void setSortAsc(Boolean sortAsc) {
		this.sortAsc = sortAsc;
	}
	public ColWidget(String colName) {
		this.colName = colName;
	}
	public final String getColName() {
		return colName;
	}
	final void setColName(String colName) {
		this.colName = colName;
	}
	public final int getColWidth() {
		if (colWidth == -1 && suggestedWidth != -1)
			return suggestedWidth; 
		return colWidth;
	}
	final void setColWidth(int colWidth) {
		this.colWidth = colWidth;
	}
	public final boolean isVisible() {
		return visible;
	}
	final void setVisible(boolean visible) {
		this.visible = visible;
	}
	public int colSpan(VO data) {
		return 1; 
	}
	public /*abstract */HorizontalAlignmentConstant alignment(VO data){return HasHorizontalAlignment.ALIGN_LEFT;}
	public String title(VO data){return "";}
}
